package com.controller;

import com.dto.CarrierMonitorDTO;
import com.dto.CarrierMonitorReqDTO;
import com.dto.MobileStationMonitorDTO;
import com.dto.PageResDTO;
import com.service.GisService;
import com.service.IMobileStationService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *特力惠es
 * </p>
 *
 * @author zhangqing
 * @since 2021/1/27
 */
@RestController
public class TlwController {
    @Autowired
    private IMobileStationService iMobileStationService;
    @Autowired
    private GisService  gisService;
    @ApiOperation(value = "流动站监控统计", notes = "流动站监控统计")
    @GetMapping("/getMobileStationMonitor")
    public ResponseEntity<List<MobileStationMonitorDTO>> getMobileStationMonitor(@ApiParam("stop:禁止;move:移动") String stateStatus, @ApiParam("搜索") String search,
                                                                                 @ApiParam("判断时间段内是静止还是移动，默认为10分钟")  Integer minite
    ){
        if(minite == null || minite == 0){
            minite = 10;
        }
        List<MobileStationMonitorDTO> list =  iMobileStationService. getMobileStationMonitor(stateStatus,search,minite);
        return ResponseEntity.ok(list);
    }

    @ApiOperation(value= "载体监控,使用原始查询,不使用实体查询 ",notes = "载体监控")
    @PostMapping("/carrierMonitor")
    public ResponseEntity< PageResDTO<CarrierMonitorDTO>> carrierMonitor(CarrierMonitorReqDTO dto){
        PageResDTO<CarrierMonitorDTO> list =   gisService.carrierMonitor(dto);
        if(list == null){
            return ResponseEntity.ok( new PageResDTO(dto.getPage(),dto.getSize(),0,0,null));
        }

        return ResponseEntity.ok(list);
    }
}
